/*
 * @Author: 无聊 7989314+Hwz1997@user.noreply.gitee.com
 * @Date: 2025-06-24 09:16:54
 * @LastEditors: 无聊 7989314+Hwz1997@user.noreply.gitee.com
 * @LastEditTime: 2025-10-27 09:49:23
 * @FilePath: \keep_motion_manger\src\api\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { instance } from '@/request';

// 登录注册
export const authApi = {
    login: (data) => instance.post('/auth/admins/login', data),
    logout: () => instance.post('/auth/admins/logout'),
}

// 系统管理
// 字典类型
export const dictTypeApi = {
    getDictType: (params) => instance.get('/sys/dict-types', { params }),
    createDictType: (data) => instance.post('/sys/dict-types', data),
    updateDictType: (id, data) => instance.put(`/sys/dict-types/${id}`, data),
    deleteDictType: (id) => instance.delete(`/sys/dict-types/${id}`),
    exportDictType: (params) => instance.get('/sys/dict-types/export', { params, responseType: 'blob' }),
}
// 字典数据
export const dictDataApi = {
    getDictData: (params) => instance.get('/sys/dict-data', { params }),
    createDictData: (data) => instance.post('/sys/dict-data', data),
    updateDictData: (id, data) => instance.put(`/sys/dict-data/${id}`, data),
    switchDictData: (id) => instance.patch(`/sys/dict-data/${id}`),
}

// 权限管理
// 菜单管理
export const menuApi = {
    getMenu: (params) => instance.get('/permission/menu', { params }),
    createMenu: (data) => instance.post('/permission/menu', data),
    updateMenu: (id, data) => instance.put(`/permission/menu/${id}`, data),
    deleteMenu: (id) => instance.delete(`/permission/menu/${id}`),
    getPath: (params) => instance.get('/permission/menu/path', { params }),
}
// 权限管理
export const permissionApi = {
    getPermission: (params) => instance.get('/permission/permissions', { params }),
    syncMenuToPermission: (data) => instance.post('/permission/permissions', data),
    bindPermission: (data) => instance.post('/permission/permissions/bind', data),
}
// 角色管理 
export const roleApi = {
    getRole: (params) => instance.get('/permission/roles', { params }),
    createRole: (data) => instance.post('/permission/roles', data),
    deleteRole: (id) => instance.delete(`/permission/roles/${id}`),
    updateRolePermission: (id, data) => instance.put(`/permission/roles/${id}`, data),
}
// 用户管理 - 管理员
export const adminApi = {
    getAdmin: (params) => instance.get('/permission/admins', { params }),
    createAdmin: (data) => instance.post('/permission/admins', data),
    updateAdmin: (id, data) => instance.put(`/permission/admins/${id}`, data),
    updateAdminStatus: (id, data) => instance.put(`/permission/admins/status/${id}`, data),
}
// 操作日志
export const auditLogApi = {
    getAuditLog: (params) => instance.get('/permission/audit-logs', { params }),
    exportAuditLog: (params) => instance.get('/permission/audit-logs/export', { params, responseType: 'blob' }),
    deleteAuditLog: (id) => instance.delete(`/permission/audit-logs/${id}`),
}

// 用户管理 
// 普通用户
export const userApi = {
    getUser: (params) => instance.get('/user/users', { params }),
    createUser: (data) => instance.post('/user/users', data),
    updateUser: (id, data) => instance.put(`/user/users/${id}`, data),
    deleteUser: (id) => instance.delete(`/user/users/${id}`)
}
// 会员等级
export const memberApi = {
    getMemberLevel: (params) => instance.get('/user/members', { params }),
    createMemberLevel: (data) => instance.post('/user/members', data),
    updateMemberLevel: (id, data) => instance.put(`/user/members/${id}`, data),
    deleteMemberLevel: (id) => instance.delete(`/user/members/${id}`),
}
// 关系管理
export const relationsApi = {
    getRelation: (params) => instance.get('/user/relations', { params }),
    createRelation: (data) => instance.post('/user/relations', data),
    deleteRelation: (id) => instance.delete(`/user/relations/${id}`),
}
// 财务管理
export const financeApi = {
    getFinance: (params) => instance.get('/user/finances', { params }),
    updateFinance: (data) => instance.put(`/user/finances`, data),
    createCard: (data) => instance.post('/user/finances/cards', data),
    deleteCard: (data) => instance.put(`/user/finances/cards`, data),
}
// 健康评估
export const assessmentApi = {
    createAssessment: (data) => instance.post('/user/assessments', data),
    getAssessments: (params) => instance.get('/user/assessments', { params }),
    updateAssessment: (id, data) => instance.put(`/user/assessments/${id}`, data),
    getAssessmentStats: (params) => instance.get('/user/assessments/stats', { params }),
}

// 课程管理
// 课程管理
export const courseApi = {
    getCourse: (params) => instance.get('/course/courses', { params }),
    getCourseDetail: (id) => instance.get(`/course/courses/${id}`),
    createCourse: (data) => instance.post('/course/courses', data),
    updateCourse: (id, data) => instance.put(`/course/courses/${id}`, data),
    deleteCourse: (id) => instance.delete(`/course/courses/${id}`),
    publishCourse: (id) => instance.patch(`/course/courses/publish/${id}`),
}
// 进度管理
export const progressApi = {
    getProgress: (params) => instance.get('/course/progress', { params }),
    updateProgress: (id, data) => instance.put(`/course/progress/${id}`, data),
    getProgressAnalytics: (params) => instance.get('/course/progress/analytics', { params }),
}

// 运动管理
// 运动类型
export const sportTypeApi = {
    getSportType: (params) => instance.get('/sport/sport-types', { params }),
    createSportType: (data) => instance.post('/sport/sport-types', data),
    updateSportType: (id, data) => instance.put(`/sport/sport-types/${id}`, data),
    deleteSportType: (id) => instance.delete(`/sport/sport-types/${id}`),
}
// 运动记录
export const sportRecordsApi = {
    getSportRecords: (params) => instance.get('/sport/sport-records', { params }),
    createSportRecords: (data) => instance.post('/sport/sport-records', data),
    updateSportRecords: (id, data) => instance.put(`/sport/sport-records/${id}`, data),
    deleteSportRecords: (id) => instance.delete(`/sport/sport-records/${id}`),
}
// 运动计划
export const trainingPlanApi = {
    getTrainingPlan: (params) => instance.get('/sport/training-plans', { params }),
    createTrainingPlan: (data) => instance.post('/sport/training-plans', data),
    updateTrainingPlan: (id, data) => instance.put(`/sport/training-plans/${id}`, data),
    recommendTrainingPlan: (id, data) => instance.patch(`/sport/training-plans/recommend/${id}`, data),
}
// 运动活动
export const sportActivityApi = {
    getSportActivity: (params) => instance.get('/sport/sport-activities', { params }),
    createSportActivity: (data) => instance.post('/sport/sport-activities', data),
    updateSportActivity: (id, data) => instance.put(`/sport/sport-activities/${id}`, data),
    getActivityParticipants: (params) => instance.get('/sport/activity-participants', { params }),
}
// 运动建议
export const sportAdviceApi = {
    getSportAdvice: (params) => instance.get('/sport/sport-advices', { params }),
    createSportAdvice: (data) => instance.post('/sport/sport-advices', data),
    updateSportAdvice: (id, data) => instance.put(`/sport/sport-advices/${id}`, data),
}

// 社区管理
// 动态管理
export const communityApi = {
    getCommunity: (params) => instance.get('/community/posts', { params }),
    deleteCommunity: (id) => instance.delete(`/community/posts/${id}`),
    pinPost: (data) => instance.patch('/community/posts/pin', data),
    deleteComment: (data) => instance.delete('/community/posts/comments', data),
}
// 收藏管理
export const collectApi = {
    getCollect: (params) => instance.get('/community/collections', { params }),
    createCollect: (data) => instance.post('/community/collections', data),
    deleteCollect: (id) => instance.delete(`/community/collections/${id}`),
    getCollectStats: (params) => instance.get('/community/collections/stats', { params }),
}
// 点赞管理
export const likeApi = {
    getLike: (params) => instance.get('/community/likes', { params }),
    createLike: (data) => instance.post('/community/likes', data),
    deleteLike: (id) => instance.delete(`/community/likes/${id}`),
    getLikeStats: (params) => instance.get('/community/likes/stats', { params }),
}